package com.letsiot.applications.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.letsiot.applications.entity.SysUserRole;
import com.letsiot.applications.service.SysUserRoleService;

@RestController
@RequestMapping("/userRole")
@Validated
public class SysUserRoleController {

    @Autowired
    private SysUserRoleService sysUserRoleService;

    @PostMapping("save")
    public int save(@RequestBody SysUserRole entity) {
        return sysUserRoleService.save(entity);
    }

    @DeleteMapping("delete")
    public int delete(Long id) {
        return sysUserRoleService.delete(id);
    }

    @PutMapping("update")
    public int update(@RequestBody SysUserRole entity) {
        return sysUserRoleService.update(entity);
    }

    @GetMapping("findById")
    public SysUserRole findById(Long id) {
        return sysUserRoleService.findById(id);
    }

    @GetMapping("getAll")
    public List<SysUserRole> getAll() {
        return sysUserRoleService.getAll();
    }

    @GetMapping("getByUserId")
    public List<SysUserRole> getByUserId(Long userId) {
        return sysUserRoleService.getByUserId(userId);
    }
}
